from typing import List


class Solution:
    def findPeakElement(self, nums: List[int]) -> int:
        left, right = 0, len(nums) - 1
        while left < right:
            mid = (left + right) // 2
            if nums[mid] > nums[mid + 1]:
                right = mid  # 峰值在左边（包含mid）
            else:
                left = mid + 1  # 峰值在右边
        return left


if __name__ == '__main__':
    s = Solution()
    r = s.findPeakElement([1, 2, 3, 1])
    print(r)
